<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shivangi Pandey on Medium]]></title>
        <description><![CDATA[Stories by Shivangi Pandey on Medium]]></description>
        <link>https://medium.com/@shivangi.pandey285?source=rss-f05e02497789------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*F3cD2imWc_UUq3Q8</url>
            <title>Stories by Shivangi Pandey on Medium</title>
            <link>https://medium.com/@shivangi.pandey285?source=rss-f05e02497789------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 22:09:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shivangi.pandey285/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Bug Tale: The 404 That Never Reached Our Code]]></title>
            <link>https://medium.com/techtrends-digest/bug-tale-the-404-that-never-reached-our-code-401928912ad4?source=rss-f05e02497789------2</link>
            <guid isPermaLink="false">https://medium.com/p/401928912ad4</guid>
            <category><![CDATA[spring-boot-bug-handling]]></category>
            <dc:creator><![CDATA[Shivangi Pandey]]></dc:creator>
            <pubDate>Sat, 11 Apr 2026 19:31:28 GMT</pubDate>
            <atom:updated>2026-04-13T12:09:57.746Z</atom:updated>
            <content:encoded><![CDATA[<p>There are bugs that announce themselves — stack traces, alerts, dashboards turning red. You know what broke, where it broke, and roughly why.</p><p>Then there are the other kind. The ones that fail silently — return a perfectly valid HTTP status code — and leave your users stranded while every monitor stays green and every dashboard looks healthy. No noise. No signal. Just quiet, invisible failure.</p><p>This is the story of one of those.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XghewwmPA4-lzdpr0K1lRw.png" /></figure><h3>The Incident</h3><p>A few users on our e-commerce platform were reported hitting 404s on order lookups. No error spike. No alerts. No upstream service degradation.</p><p>What made it <em>intriguing</em>:</p><ul><li>Same API. Same deployment. Same environment.</li><li>Same endpoint. Same code path.</li><li><strong>~10–15% of order lookup requests silently returning 404</strong> — with zero application-level error logs.</li></ul><p>Partial failure. No stack trace. No obvious discriminator.</p><h3>Debugging Direction: Where Do You Even Start?</h3><p>When a failure has no error, no stack trace, and no obvious pattern, the instinct is to reach for the nearest log file — usually your service logs.</p><p>That instinct is wrong.</p><p>The right approach is to follow the <strong>request execution path</strong> from entry to exit, one layer at a time, and identify the exact boundary where behaviour changes from expected to unexpected. Not guess. Not sample. Trace.</p><p>In our system, that path was:</p><p>Start at the outermost layer. Move inward only when the outer layer is cleared.</p><h3>Layer 1: API Gateway — Start at the Entry Point</h3><p>The temptation in any production incident is to grep your service logs first. That’s the wrong instinct.</p><p><strong>Always start where the request enters your system.</strong></p><p>Gateway logs surfaced this within minutes:</p><pre>GET /orders/ABC123   → 200 OK   ✅<br>GET /orders/ABC/123  → 404 Not Found ❌</pre><p>Critical observation: <strong>both requests reached the gateway</strong>. The gateway received them, processed them, and returned a response. That single fact eliminated an entire class of suspects:</p><ul><li>❌ Network connectivity issues</li><li>❌ DNS resolution failures</li><li>❌ Gateway availability problems</li></ul><p>The failure was happening <em>inside</em> the gateway’s routing logic — before the request was ever proxied downstream.</p><h3>Layer 2: Request Tracing — Follow the Execution Path</h3><p>Using correlation IDs, I traced the full request lifecycle for both a successful and a failed request.</p><p><strong>Successful request:</strong></p><pre>Client → Gateway (route matched) → Service → DB → 200 Response</pre><p><strong>Failed request:</strong></p><pre>Client → Gateway (route not matched) → 404 returned<br>         ↑<br>         stops here. service never invoked.</pre><p>Service logs: <strong>completely silent</strong> for failed requests.</p><p>This is the inflection point of the entire investigation:</p><blockquote><em>If a request never reaches your service, debugging inside your service is categorically the wrong approach.</em></blockquote><p>The failure boundary was the gateway’s routing layer. Everything downstream — application logic, database queries, connection pools — was irrelevant noise.</p><h3>Layer 3: Eliminating the Wrong Suspects</h3><p>At this point we briefly investigated:</p><ul><li>DB connection pool exhaustion</li><li>Load balancer health checks</li><li>Service instance availability</li></ul><p>All healthy. All irrelevant.</p><p>This is worth naming explicitly:</p><blockquote><strong><em>Systematic debugging means eliminating layers, not randomly sampling them.</em></strong><em> Each dead end is signal, not failure — it narrows your search space deterministically.</em></blockquote><h3>The Discriminator: Input Comparison</h3><p>What made this particularly <em>intriguing</em> was that every typical reason for a production failure had checked out fine — the service was healthy, the database was responsive, connection pools were within normal bounds, the load balancer was routing correctly. All the usual suspects were eliminated.</p><p>That’s when I stepped back from infrastructure entirely and went back to basics: the actual inputs themselves. Sometimes the most valuable debugging step isn’t going deeper — it’s going <em>sideways</em>.</p><p>I pulled a sample of failed and successful request logs side by side and compared them directly.</p><pre>✅ GET /orders/ABC123     → routes correctly<br>❌ GET /orders/ABC/123    → 404</pre><p>One character separated success from failure: <strong>a forward slash inside the </strong><strong>orderId value</strong>.</p><h3>Root Cause: How HTTP Path Routing Actually Works</h3><p>This is where it gets technically interesting.</p><p>Our Spring Boot controller was defined as:</p><p>java</p><pre>@GetMapping(&quot;/orders/{orderId}&quot;)<br>public ResponseEntity&lt;Order&gt; getOrder(@PathVariable String orderId) {<br>    return orderService.findById(orderId);<br>}</pre><p>When the request /orders/ABC/123 arrived, Spring&#39;s DispatcherServlet — specifically the RequestMappingHandlerMapping — parsed the URI path using / as a <strong>segment delimiter</strong>:</p><pre>Path segments: [&quot;orders&quot;, &quot;ABC&quot;, &quot;123&quot;]<br>Template:      [&quot;orders&quot;, &quot;{orderId}&quot;]</pre><p>Result: <strong>pattern mismatch</strong>. The template has 2 segments, the request has 3. No handler found. Spring returns 404 directly from the routing layer — DispatcherServlet never delegates to your controller.</p><h3>Why This Behaviour Is Correct (Not a Bug)</h3><p>Per <a href="https://datatracker.ietf.org/doc/html/rfc3986">RFC 3986</a>, / is a <strong>reserved character</strong> in URI path components. It is a structural delimiter, not data. Using it inside a path parameter value violates the URI specification.</p><p>This is not a Spring bug. This is not a framework quirk. This is HTTP.</p><p>Most frameworks implement this identically:</p><ul><li><strong>Spring MVC</strong> — RequestMappingHandlerMapping splits on / before pattern matching</li><li><strong>Express.js</strong> — path-to-regexp treats / as a segment boundary by default</li><li><strong>Django</strong> — URL patterns use [^/]+ regex by default, explicitly excluding slashes</li><li><strong>ASP.NET Core</strong> — route constraints reject / in path parameters</li></ul><blockquote><strong><em>The bug never existed in application code. It existed in a violated assumption about what values are valid in a URI path segment.</em></strong></blockquote><h3>Evaluating the Fix — A Design Decision, Not a Patch</h3><p>Once root cause was confirmed, we evaluated four remediation strategies.</p><p>For a detailed technical breakdown of each approach — including URL encoding edge cases, allowEncodedSlashes configuration risks, and regex-based path matchers — read:</p><p>👉 <a href="https://medium.com/techtrends-digest/handling-special-characters-in-path-parameters-best-practices-and-solutions-412b02751131">Handling Special Characters in Path Parameters — Best Practices and Solutions</a></p><p>Summary of options:</p><p>OptionTechnical RiskPercent-encode (%2F)Inconsistent decode behaviour across proxies and gateways (Nginx, AWS ALB decode %2F before routing)allowEncodedSlashes=true on serverSecurity risk — path traversal attack surface, double-decode vulnerabilitiesStrip/replace slashes on inputMutates data — breaks ID integrity<strong>Move to query parameterNo routing ambiguity. RFC-compliant. Framework-safe. ✅</strong></p><p>Query parameters are parsed <strong>after</strong> path routing. They are outside the URI path component entirely — meaning the routing layer never touches them. No encoding issues, no framework quirks, no security tradeoffs.</p><h3>The Fix</h3><pre>// Before — path parameter: fragile when orderId contains reserved characters<br>@GetMapping(&quot;/orders/{orderId}&quot;)<br>public ResponseEntity&lt;Order&gt; getOrder(@PathVariable String orderId) {<br>    return orderService.findById(orderId);<br>}</pre><pre>// After — query parameter: routing-layer safe<br>@GetMapping(&quot;/orders&quot;)<br>public ResponseEntity&lt;Order&gt; getOrder(@RequestParam String orderId) {<br>    return orderService.findById(orderId);<br>}</pre><pre># Before<br>GET /orders/ABC/123</pre><pre># After  <br>GET /orders?orderId=ABC%2F123</pre><h3>Engineering Guardrails: Closing the Gap</h3><p><strong>1. API boundary validation with explicit character contracts</strong></p><pre>private static final Pattern SAFE_ID = Pattern.compile(&quot;^[A-Za-z0-9_-]+$&quot;);</pre><pre>if (!SAFE_ID.matcher(orderId).matches()) {<br>    return ResponseEntity.badRequest()<br>        .body(&quot;orderId contains reserved URI characters&quot;);<br>}</pre><p>Fail fast with 400 Bad Request — not silent 404. Give clients actionable error information.</p><p><strong>2. Contract testing with production-representative data</strong></p><p>Your test suite should include IDs from every upstream system that generates them — including legacy integrations. Real-world identifiers contain slashes, colons, dots, and spaces. Your path parameters shouldn’t.</p><p><strong>3. Gateway-level observability as baseline infrastructure</strong></p><p>Distributed tracing with correlation IDs from the gateway down should be default — not reactive. By the time you need it, it’s too late to instrument.</p><h3>Key Takeaways</h3><p><strong>1. Debug by eliminating layers, not sampling them</strong> Gateway → Service → DB — each is a checkpoint. Localise the failure boundary first. Everything outside that boundary is noise.</p><p><strong>2. Path parameters have an implicit type constraint</strong> The moment a value becomes a path segment, you’ve constrained its character set to [A-Za-z0-9._~!$&amp;&#39;()*+,;=:@-] (RFC 3986 unreserved + sub-delimiters). Treat this as a type — enforce it explicitly.</p><p><strong>3. “Random” failures are conditional failures with an undiscovered discriminator</strong> The discriminator here was a single character class. Find the input that splits success from failure and the bug becomes deterministic.</p><p><strong>4. Framework routing is infrastructure — understand it</strong> DispatcherServlet, path-to-regexp, Django URL resolvers — these aren&#39;t black boxes. They implement RFC 3986. Read the spec once and it pays dividends forever.</p><p><strong>5. Production data violates assumptions that test data never will</strong> Legacy system integrations are the most common source of unexpected character sets in identifiers. Test accordingly.</p><h3>Final Thought</h3><p>This was not a complex bug.</p><p>It <em>looked</em> complex because it failed conditionally, failed at the infrastructure layer, and produced a response that looked intentional.</p><blockquote><strong><em>The earlier a system rejects a request, the harder the bug is to find — unless you know exactly which layer to instrument first.</em></strong></blockquote><p>Bugs don’t always live in your code. Sometimes they live in the contract between your code and the protocol it runs on.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=401928912ad4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techtrends-digest/bug-tale-the-404-that-never-reached-our-code-401928912ad4">Bug Tale: The 404 That Never Reached Our Code</a> was originally published in <a href="https://medium.com/techtrends-digest">Coffee☕ And Code💚</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Goldman Sachs SDE2 Interview Experience]]></title>
            <link>https://medium.com/techtrends-digest/my-goldman-sachs-sde2-interview-experience-a1d927860ab0?source=rss-f05e02497789------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1d927860ab0</guid>
            <dc:creator><![CDATA[Shivangi Pandey]]></dc:creator>
            <pubDate>Thu, 02 Oct 2025 19:04:20 GMT</pubDate>
            <atom:updated>2025-12-16T13:10:11.601Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently went through the interview process at <strong>Goldman Sachs</strong> for the role of <strong>SDE2 / Associate Engineer</strong>. With around <strong>4 years of experience</strong> in backend development (Java, Spring Boot, and distributed systems), I wanted to share my journey — not just the rounds but also the kind of preparation that helped me.</p><p>The process took place in <strong>April (about 4–5 months ago)</strong>, and I’m happy to share that I received an <strong>offer letter</strong> at the end of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jFDiCm2xyQDM4wVAmV0M1g.png" /></figure><h3>Application Process</h3><p>I applied online for the <strong>Goldman Sachs Bangalore office</strong>. The role was <strong>SDE2/Associate</strong>. Soon after, I was invited to take the <strong>HackerRank Online Assessment</strong>.</p><h3>Round 1: HackerRank (Online Coding Assessment)</h3><p>The HackerRank round consisted of <strong>3 coding problems</strong>. While I don’t remember the exact problems, they were mostly in the range of <strong>medium-level DSA and implementation</strong>.</p><p>The difficulty was fair — not too tough, but required speed and accuracy. Clearing this round led to the next stage.</p><h3>Round 2: CoderPad Technical Round</h3><p>This was a <strong>live coding + discussion</strong> round, conducted on <strong>CoderPad</strong>. The interviewer asked me one main coding problem along with some <strong>Java basics</strong> and <strong>project-related discussions</strong>.</p><ul><li><strong>Problem:</strong><br> You’re given two arrays — one representing processes and the other representing their parent IDs. Given a target process ID, you have to “kill” that process and all of its child processes.</li><li>I solved it using a <strong>graph traversal (BFS/DFS)</strong> approach, treating the processes as a tree of dependencies.</li></ul><p>Apart from this, there were follow-up discussions around:</p><ul><li>My recent <strong>Spring Boot projects</strong></li><li><strong>Concurrency basics</strong> in Java</li><li>Handling scalability in distributed systems</li></ul><h3>Superday (Onsite Virtual Interviews)</h3><p>After clearing the initial rounds, I was invited for the <strong>Superday</strong>, which is Goldman’s way of conducting <strong>multiple back-to-back technical interviews</strong> in one stretch.</p><p>In my case, the Superday consisted of <strong>3 consecutive rounds (Round 3, Round 4, and Round 5)</strong> — each testing different aspects of problem-solving, design, and real-world engineering knowledge.</p><h3>Round 3: DSA + Strings + Greedy</h3><p>This was purely <strong>DSA-focused</strong>. The interviewer asked two problems:</p><ol><li><strong>String Palindrome Check with One Removal(similar problem)</strong><br> → Given a string, check if it can become a palindrome by removing at most one character. (Classic LeetCode easy/medium).</li><li><strong>Greedy Problem (Hard Variation)</strong><br> → A problem similar to LeetCode hard, requiring greedy decision-making with constraints. This tested clarity of thought and optimization.</li></ol><p>The key here was to think <strong>out loud</strong> and explain trade-offs while coding.</p><h3>Round 4: Git Flow + HLD Component + DSA</h3><p>This round was a mix of <strong>system design discussion + coding</strong>.</p><ul><li>We discussed <strong>Git branching strategy</strong> in real-world projects (feature branching, release flow, hotfixes).</li><li>A <strong>mini HLD discussion</strong>: the interviewer picked a component from a larger system and asked how I would approach its design.</li><li><strong>Problem:</strong> Restore IP Addresses (LeetCode classic backtracking problem).</li></ul><p>This was a fun round since it combined both <strong>practical engineering practices</strong> and <strong>algorithmic thinking</strong>.</p><h3>Round 5: Concurrency + Graph Traversal</h3><p>The third Superday round focused on <strong>concurrency + DSA</strong>.</p><ul><li><strong>Problem:</strong> Number of Islands (connected components in a grid using DFS/Union Find).</li><li>Discussion around <strong>handling multiple incoming requests via ThreadPool</strong>.</li><li><strong>Concurrency</strong> — Coding-style discussion: multi-threading, locks, race conditions, BlockingQueue, thread-safety.</li><li>Scaling requests</li><li>Avoiding bottlenecks</li></ul><p>This round tested both <strong>coding fluency</strong> and <strong>system-level awareness</strong>.</p><h3>Round 6: LLD + HLD + Databases</h3><p>The final technical round was <strong>deep-dive into design</strong>:</p><ol><li><strong>LLD &amp; HLD of an E-commerce Platform</strong></li></ol><ul><li>Cart, Orders, Payments</li><li>How to handle scaling and reliability</li></ul><p><strong>2. Database Internals</strong></p><ul><li>How indexing works internally</li><li>How NoSQL stores data and how queries are optimized</li></ul><p>3.Trade-offs between SQL and NoSQL in real-world scenarios</p><p>This round required both <strong>breadth and depth</strong> of system knowledge.</p><h3>Outcome</h3><p>A few weeks later, I received the <strong>offer letter from Goldman Sachs 🎉</strong>.</p><h3>Takeaways &amp; Preparation Tips</h3><ul><li><strong>DSA:</strong> Practice standard LeetCode problems (focus on graphs, strings, and backtracking).</li><li><strong>Java:</strong> Understand thread pools, synchronization, and how concurrency works in backend systems in addition to other core Java concepts.</li><li><strong>System Design:</strong> Be ready for both high-level (HLD) and low-level design (LLD). Common systems design question include e-commerce, notification system, and caching.</li><li><strong>Git &amp; Engineering Practices:</strong> Know practical workflows (branching, CI/CD basics, deployments).</li></ul><h3>Final Thoughts</h3><p>The Goldman Sachs interview process was challenging but also very <strong>well-rounded</strong>. It not only tested my <strong>DSA skills</strong>, but also my <strong>practical backend engineering knowledge</strong> and <strong>design thinking</strong>.</p><p>If you’re preparing, I’d recommend balancing your prep between:</p><ul><li><strong>LeetCode practice</strong></li><li><strong>System design case studies</strong></li><li><strong>Core Java</strong></li></ul><p>It was a great learning experience for me, I hope this experience helps future candidates get a sense of what to expect. With the right preparation and mindset, the process is definitely crackable. 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1d927860ab0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techtrends-digest/my-goldman-sachs-sde2-interview-experience-a1d927860ab0">My Goldman Sachs SDE2 Interview Experience</a> was originally published in <a href="https://medium.com/techtrends-digest">Coffee☕ And Code💚</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handling Special Characters in Path Parameters: Best Practices and Solutions]]></title>
            <link>https://medium.com/techtrends-digest/handling-special-characters-in-path-parameters-best-practices-and-solutions-412b02751131?source=rss-f05e02497789------2</link>
            <guid isPermaLink="false">https://medium.com/p/412b02751131</guid>
            <dc:creator><![CDATA[Shivangi Pandey]]></dc:creator>
            <pubDate>Mon, 18 Nov 2024 20:09:06 GMT</pubDate>
            <atom:updated>2026-04-11T16:32:38.267Z</atom:updated>
            <content:encoded><![CDATA[<p>When working with web applications, handling special characters (e.g., /) in path parameters often requires careful consideration. This guide outlines various approaches to address such scenarios, using Spring Boot and Feign Client as examples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ON6OEpsSH5XerC68sYAqYg.png" /></figure><h3>1. Change Path Parameter to Query Parameter</h3><h4>Approach:</h4><p>Replace the path parameter with a query parameter to avoid encoding issues.</p><h4>Example:</h4><p>Before:</p><pre>@GetMapping(&quot;/orders/{orderId}&quot;)<br>public Order getOrderDetails(@PathVariable String orderId) { ... }</pre><p>After:</p><pre>@GetMapping(&quot;/orders&quot;)<br>public Order getOrderDetails(@RequestParam String orderId) { ... }</pre><h4>Trade-offs:</h4><ul><li><strong>Advantages</strong>: Simple to implement.</li><li><strong>Disadvantages</strong>: Query parameters are generally used for filtering or optional inputs, are not ideal for uniquely identifying resources and can create ambiguity in API design.</li></ul><p>This approach might work for our usecase where retaining the encoded orderId is necessary. However, it’s <strong>not recommended</strong> for clean and intuitive RESTful API design.</p><h3>2. Allow Encoded Paths in Spring Boot</h3><h4>Approach:</h4><p>Enable encoded characters in path parameters by configuring the Spring Boot firewall.</p><h4>Steps:</h4><p>Add the following to your Spring configuration:</p><pre>@Bean public HttpFirewall allowEncodedPathsFirewall() {<br> StrictHttpFirewall firewall = new StrictHttpFirewall();     <br>  firewall.setAllowUrlEncodedSlash(true);     <br>  return firewall; <br>}</pre><p>Update the application properties:</p><pre>server.tomcat.relaxed-path-chars=&lt;&gt;[]^`{|}<br>server.tomcat.relaxed-query-chars=&lt;&gt;[]^`{|}</pre><h4>Trade-offs:</h4><ul><li><strong>Advantages</strong>: Retains RESTful structure with path parameters.</li><li><strong>Disadvantages</strong>: User-facing apps may become prone to security vulnerabilities such as path traversal attacks.</li></ul><h3>3. Parse the Path Manually and Encode Special Characters</h3><h4>Approach:</h4><p>Use wildcard path mappings (/**) to capture the entire path, including special characters, and encode them manually before further processing.</p><h4>Example:</h4><p>Controller:</p><pre>@GetMapping(&quot;/orders/**&quot;)<br>public ResponseEntity&lt;Order&gt; getOrderDetails(HttpServletRequest request) {<br>    String fullPath = request.getRequestURI();<br>    String encodedOrderId = fullPath.substring(fullPath.lastIndexOf(&quot;/&quot;) + 1);<br>    // Process encodedOrderId<br>    ...<br>}</pre><p>Feign Client:</p><p><strong>Feign Configuration</strong>: Using decodeSlash = false ensures that encoded slashes are preserved in Feign client calls, which is crucial for passing the data to downstream services.</p><pre>@FeignClient(name = &quot;ch-service&quot;, configuration = FeignConfig.class)<br>public interface ChServiceClient {<br>    @GetMapping(value = &quot;/ch/orders/{orderId}&quot;, decodeSlash = false)<br>    ResponseEntity&lt;Order&gt; getOrder(@PathVariable(&quot;orderId&quot;) String orderId);<br>}</pre><h4>Trade-offs:</h4><ul><li><strong>Advantages</strong>: Provides a workaround without enabling encoded paths globally.</li><li><strong>Disadvantages</strong>: Increases complexity and may break existing code.</li></ul><h3>4. Convert GET to POST for Encoding Assurance</h3><h4>Approach:</h4><p>Switching from GET to POST for handling special characters is functional but <strong>violates REST principles</strong>. POST is generally meant for creating resources, while GET is used for retrieval.</p><h4>Example:</h4><p>Controller:</p><pre>@PostMapping(&quot;/orders/details&quot;)<br>public Order getOrderDetails(@RequestBody String orderId) { ... }</pre><h4>Trade-offs:</h4><ul><li><strong>Advantages</strong>: Encoded characters are safely passed in the request body.</li><li><strong>Disadvantages</strong>:</li><li>Violates REST principles if the operation is purely read-only. This approach is viable only when flexibility in API design is acceptable.</li><li>Misleading Semantics: Using POST for a read operation can confuse API consumers and reduce clarity.</li><li>Compatibility: If the endpoint is already used as a GET, changing it to POST will break existing clients.</li></ul><h3>Conclusion</h3><p>The choice of approach depends on the context:</p><ul><li>For <strong>microservices communication</strong>, using encoded paths with manual parsing or configuration changes might work best.</li><li>For <strong>public APIs</strong>, prioritize design clarity and consider switching to query parameters or using POST requests for special cases.</li></ul><p>Each approach has its pros and cons; evaluate them based on the system’s requirements and security concerns.</p><p><strong>Thanks, and I hope you enjoyed it and had fun reading it.😊🎉</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=412b02751131" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techtrends-digest/handling-special-characters-in-path-parameters-best-practices-and-solutions-412b02751131">Handling Special Characters in Path Parameters: Best Practices and Solutions</a> was originally published in <a href="https://medium.com/techtrends-digest">Coffee☕ And Code💚</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Accept-Language header in software localization]]></title>
            <link>https://medium.com/@shivangi.pandey285/accept-language-header-in-software-localization-d42c655f4108?source=rss-f05e02497789------2</link>
            <guid isPermaLink="false">https://medium.com/p/d42c655f4108</guid>
            <dc:creator><![CDATA[Shivangi Pandey]]></dc:creator>
            <pubDate>Sun, 24 Mar 2024 20:33:33 GMT</pubDate>
            <atom:updated>2024-03-25T17:51:45.179Z</atom:updated>
            <content:encoded><![CDATA[<h3>Accept-Language header in software localisation</h3><p><strong>Ever wondered how websites know your language preferences without asking</strong>🤔 ?<br>The answer is <strong><em>Accept-Language header</em></strong>.<br>The Accept-Language header plays a crucial role in software localisation by indicating the preferred language(s) of the user’s browser or client application. This clever feature was designed to enhance your web browsing experience by making it smoother and more personalized, ensuring content is presented in the language you’re most comfortable with whenever possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*XfAfpl6IUxXwTSMedmv-6w.png" /></figure><p>When a user interacts with a web application or service, their browser automatically includes this header in the HTTP request sent to the server.<br>The Accept-Language header can be used to determine the user’s preferred language and tailor the content or user interface accordingly. This enables the server to provide responses, such as web pages or API messages, in the language that best suits the user’s preferences. For example, if a user’s browser sends an Accept-Language header indicating French as the preferred language, the server can serve content in French if available.</p><p><strong>Accept-Language header structure<br></strong>The Accept-Language header structure typically consists of a list of language tags, each representing a language and optional country or region code. The header follows the format:</p><pre>Accept-Language: language-tag1, language-tag2, ...</pre><p>Here, each language tag is formatted according to the BCP 47 standard, which specifies a two-letter primary language subtag (e.g., “en” for English, “fr” for French) followed by an optional subtag for country or region (e.g., “US” for United States, “CA” for Canada). The tags are separated by commas, with an optional quality parameter (q) indicating the preference for each language, ranging from 0 to 1.</p><p>Servers can use this information to determine the most suitable language for the user and serve content accordingly. If a requested language is unavailable, servers may fall back to a default language or provide content in another available language.</p><p><strong>Note</strong>:-Remember, the server isn’t obligated to strictly follow the Accept-Language header value. Instead, it serves as a helpful suggestion, guiding the server to better understand a user’s language preferences and attempting to provide the most suitable content. Nevertheless, the server ultimately makes the final decision on which language version to deliver, considering factors like content availability, server configuration, or other constraints.</p><p><strong>Accept-Language header examples</strong><br>1)Simple Language Preference:</p><pre>Accept-Language: en-US,</pre><p>Without q factor indicate en-US has a preference equivalent to q=1, this indicates that the user prefers English with the United States locale.</p><p>2)Multiple Language Preferences with Quality Parameters:</p><pre>Accept-Language: en-US, fr;q=0.8, es;q=0.5</pre><ul><li>“en-US” indicates English language preference with the United States locale.</li><li>“fr;q=0.8” indicates a preference for French with a quality parameter of 0.8, suggesting a slightly lower preference compared to English.</li><li>“es;q=0.5” indicates a preference for Spanish with a quality parameter of 0.5, indicating lower preference compared to both English and French.<br>This suggests that the user prefers English (United States) the most, followed by French with a slightly lower preference (0.8), and Spanish with the lowest preference (0.5).</li></ul><p>3)Language Preferences with Regions:</p><pre>Accept-Language: de-DE, en-US;q=0.8, en;q=0.6</pre><p>Here, the user prefers German (Germany) the most, followed by English (United States) with a slightly lower preference (0.8), and then English in general with an even lower preference (0.6).</p><p>4)Wildcard for Any Language:</p><pre>Accept-Language: *</pre><p>This indicates that the user accepts content in any language. It’s typically used when the user has no specific language preference or when the server should determine the best language to serve based on available content.</p><p>These examples illustrate how the Accept-Language header communicates language preferences from the client to the server, allowing for appropriate content negotiation and localisation.</p><p><strong>Thanks, and I hope you enjoyed it and had fun reading it.😊🎉</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d42c655f4108" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generate Unique Positive Long Number]]></title>
            <link>https://medium.com/techtrends-digest/generate-unique-positive-long-number-f6d8734023a3?source=rss-f05e02497789------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6d8734023a3</guid>
            <dc:creator><![CDATA[Shivangi Pandey]]></dc:creator>
            <pubDate>Sat, 11 Mar 2023 21:10:35 GMT</pubDate>
            <atom:updated>2026-01-23T09:45:45.378Z</atom:updated>
            <content:encoded><![CDATA[<h4>Intend:</h4><p><em>To generate unique positive long number in java</em></p><p>This blog is to help developers looking forward to approaches for producing unique long numbers in Java to fulfil business requirements such as in applications for tracking transactions .This can also be referred for generating unique number of type double as illustrated in example2 below.</p><p>In this tutorial, I am gonna guide you through the different ways you can generate a unique positive long number in Java. Before diving into detail, let me tell you that generating a unique number of primitive type long is not as straightforward as generating strings even after having the privilege of libraries like UUID, as current Java-supported libraries don’t directly support this functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hrH3HI3AH9c2alB1ZQHFBA.png" /></figure><p>Java provides different ways to generate random numbers, using some built-in methods and classes, but most of them do generate unique positive long numbers, like the java.util.Random class, the Math.random method the ThreadLocalRandom class, and many others. But since randomness doesn’t guarantee uniqueness, which means a random number generated by those methods need not be unique, this can be verified by providing a small range to Random().</p><p><strong>Example 1:</strong></p><pre>// Java Program to generate Random Number Between 1-4 using random() function<br>import java.io.*;<br>import java.util.Random;<br>class GFG {<br>public static void main(String[] args)<br>{<br>Random random = new Random();<br>// initialize variable rand with 0<br>int rand = 0;<br>while (true) {<br>// rand will store one of the random value between 0-4 described using nextInt(5) below in random.nextInt(5)<br>rand = random.nextInt(5);<br>if (rand != 0)<br>break;<br>}<br>System.out.println(rand);<br>}<br>}</pre><p><strong>Output:</strong></p><pre>3</pre><p><strong>Example 2:</strong></p><pre>// Java Program to generate random double numbers using random() function<br>import java.io.*;<br>import java.util.Random;<br>class UniqueNumberGenerator {<br>public static void main(String[] args)<br>{<br>Random random = new Random();<br>// to get a random and most likely unique double value use nextDouble() with random<br>double d = random.nextDouble();<br>System.out.println(d);<br>double d1 = Math.random();<br>System.out.println(d1);<br>}<br>}</pre><p><strong>Output:</strong></p><pre>0.48783050588815524<br>0.05301287078228778</pre><p>Few other libraries which are actually capable of producing unique numbers come with the drawback that the output number includes both positive and negative numbers; uniqueness might be followed here, but if the requirement is aligned towards producing a positive unique number, these libraries will not be useful.</p><h4>Solution approach:</h4><p><em>To produce a positive unique (with extremely low chances of repetition) long value in Java, the well-known UUID library, which is also widely used for generating unique strings, can be used. With UUID, a unique long number of the desired length can be obtained as below.</em></p><p><strong>Approach 1</strong>:UUID.randomUUID().toString() produces a unique string of length 36 that is made up of characters (alphabets and “-”) and digits.</p><pre>// Java Program To use UUID to generate long positive values with BigInteger<br>import java.math.BigInteger;<br>import java.util.UUID;<br>class UniqueNumberGenerator {<br>public static void main(String[] args)<br>{<br>// The UUID.randomUUID().toString() of length consist of digits ,alphabets which will be handled to get digits using BigInteger and &quot;-&quot; which needs to be replaced with &quot;&quot;. Inside  new BigInteger(&quot;%010d&quot;, new BigInteger(UUID.randomUUID().toString().replace(&quot;-&quot;, &quot;&quot;), 16)) 16 represent radix .<br>String generateUUIDNo = String.format(&quot;%010d&quot;,new BigInteger(UUID.randomUUID().toString().replace(&quot;-&quot;,&quot;&quot;),16));<br>// To decide length of unique positive long number generateUUIDNo.length() - uniqueNoSize is being used<br>long unique_no = Long.parseLong(generateUUIDNo.substring( generateUUIDNo.length() - 10));<br>System.out.println(unique_no);<br>}<br>}</pre><p><strong>Output:</strong></p><pre>9918386712</pre><p>Where uniqueNoSize represents the size of the unique number required, it should be less than or equal to 38 as generateUUIDNo length is 38.</p><p><strong>Approach 2</strong>: Using UUID library and returning absolute long value using Math.abs().</p><pre>import java.util.UUID;<br><br>public class UniqueNumberGenerator {<br>    public static void main(String[] args) {<br>        UUID uniqueID = UUID.randomUUID();<br>        long unique_no = Math.abs(uniqueID.getMostSignificantBits());<br>        System.out.println(unique_no);<br>    }<br>}</pre><p><strong>Output:</strong></p><pre>7115316134369051261</pre><p><strong>Approach 3</strong>: This approch to showcase generation of unique long value without the use of UUID library, this being the simplest approach and uses the System.currentTimeMillis() method, which returns the current time in milliseconds for generating unique long positive value.</p><pre>public class UniqueNumberGenerator {<br>    public static void main(String[] args) {<br>        long unique_no = System.currentTimeMillis();<br>        System.out.println(unique_no);<br>    }<br>}</pre><p><strong>Output:</strong></p><pre>1678908587248</pre><p><strong>Note</strong>:They are not the only solution, but there are definitely others. I had tried to bring forward a few of the approaches.</p><p><strong>Thanks, and I hope you enjoyed it and had fun reading it.☺️🎉</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6d8734023a3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techtrends-digest/generate-unique-positive-long-number-f6d8734023a3">Generate Unique Positive Long Number</a> was originally published in <a href="https://medium.com/techtrends-digest">Coffee☕ And Code💚</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Restricting ingress to internal for Cloud Run in GCP using Terraform]]></title>
            <link>https://medium.com/@shivangi.pandey285/restricting-ingress-to-internal-for-cloud-run-in-gcp-using-terraform-9ef5dbb8a840?source=rss-f05e02497789------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ef5dbb8a840</guid>
            <dc:creator><![CDATA[Shivangi Pandey]]></dc:creator>
            <pubDate>Tue, 01 Nov 2022 20:19:42 GMT</pubDate>
            <atom:updated>2022-11-08T05:29:45.954Z</atom:updated>
            <content:encoded><![CDATA[<h4>Overview</h4><p>Hello, and welcome to this post. Here we will discuss an approach to setting ingress as internal in Cloud Run in GCP.</p><h4>Problem Statement</h4><blockquote>To set ingress as internal in the Cloud Run service in GCP using Terraform, while modifying an existing or when creating a new cloud run service in GCP through Terraform.</blockquote><p>Before going into detail, let’s see what we meant by ingress and terraform below .</p><h4>Ingress</h4><p>Ingress settings are used to restrict network access to your Cloud Run service in GCP .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FHPhK6XpHHGq3go2QrgBcA.png" /></figure><h4>Terraform</h4><p>Terraform is used here to describe Infrastructure as Code (IaC) tools that allow you to manage infrastructure with configuration files rather than through a graphical user interface.</p><p>IaC allows you to build, change, and manage your infrastructure in a safe, consistent, and repeatable way by defining resource configurations that you can version, reuse, and share.</p><p>Here, we are using Terraform to manage the infrastructure for GCP cloud services.</p><h4>Solution approach</h4><p>The configuration that needs to be setup for cloudrun resources in the main.tf or respective.tf file is given below.</p><p>metadata {<br>annotations = {<br>“run.googleapis.com/ingress” = “all”<br>}<br>}</p><p>Below is the complete configuration for the sample cloud run service . The above Metadeta setup must be placed outside the template in the resource as below.</p><p>resource “google_cloud_run_service” “load_test_cloudrun” {<br>metadata {<br>annotations = {<br>“run.googleapis.com/ingress” = “internal”<br>}<br>template {<br>.<br>.<br>}</p><p>To add for clarification, the ingress setup of cloud run in GCP can also be done manually very easily while creating a new cloud run service, the above configuration is to achieve the same using Terraform.</p><p>Thanks, and I hope you enjoyed it and had fun reading it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ef5dbb8a840" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[To build generic, custom defined timer metrics using StackDriver]]></title>
            <link>https://medium.com/@shivangi.pandey285/custom-defined-metrics-in-stackdriver-micrometer-with-names-for-custom-metric-stored-in-an-iterable-678a2a5d2e0c?source=rss-f05e02497789------2</link>
            <guid isPermaLink="false">https://medium.com/p/678a2a5d2e0c</guid>
            <dc:creator><![CDATA[Shivangi Pandey]]></dc:creator>
            <pubDate>Mon, 17 Oct 2022 18:58:36 GMT</pubDate>
            <atom:updated>2022-11-08T19:10:32.907Z</atom:updated>
            <content:encoded><![CDATA[<h4>Overview</h4><p>Hello, and welcome to this post. It talks about building generic, custom defined timer metrics using StackDriver.</p><h4>Problem Statement</h4><blockquote>To create custom defined generic metrics for n distinct events in Stackdriver Micrometer</blockquote><p>To understand the use case, consider the example of a pizza shop with a variety of pizzas, including “Veg Extravaganza”, “Farm House”, “Deluxe Veggie” and “Mexican Green”. You want to graphically explore the data for each kind of pizza, like, count of orders made for each kind, etc.</p><h4>Solution approach</h4><p>Here, the metric name for your custom metrics is stored in an iterable data structure list in Java.</p><h4>Here we are illustrating a timer in the Stackdriver metre registry, the same can be applied and used for guage, counter etc.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tz-XbSovPmRG1kwKLBj5kg.png" /></figure><p>In class PrepareVegPizza, we have a list of vegPizzaTypes inside a function, and we will loop through the list and call the generateMetric(String,long) method from the MetricsBuilder class.</p><pre>List&lt;String&gt; vegPizzaTypes= Arrays.<em>asList</em>(new String[]{&quot;Veg Extravaganza&quot;, &quot;Farm House&quot;, &quot;Deluxe Veggie&quot;, &quot;Mexican Green&quot;});</pre><pre>vegPizzaTypes.stream().forEach(vegPizza-&gt;metricsBuilder.generateMetric(vegPizza,vegPizzaTypes.indexOf(vegPizza)));</pre><p>Now coming to MetricsBuilder class</p><pre>import io.micrometer.core.instrument.MeterRegistry;<br>import org.springframework.stereotype.Service;<br>import java.util.concurrent.TimeUnit;<br>import static io.micrometer.core.instrument.Timer.<em>builder</em>;<br><br>@Service<br>class MetricsBuilder{<br><br>    @Autowired<br>    private MeterRegistry registry;<br><br>    public void generateMetric(String PizzaType, long timeToBake) throws InterruptedException {<br><br>        <em><br>        builder</em>(PizzaType)<br>                .description(&quot;This will calculate time taken to bake&quot;+PizzaType)<br>                .publishPercentiles(0.50, 0.95)<br>                .publishPercentileHistogram()<br>                .register(registry).record(5000*timeToBake, TimeUnit.<em>MILLISECONDS</em>);<br>    }<br>}</pre><p>Using this, we are defining custom metrics with names of PizzaType from vegPizzaType in the registry. The publishPercentiles(0.50, 0.95) will show values in 50 and 95 percentile standards while plotting the histogram. The record(long value, TimeUnit) method, which is used to record the long value for TimeUnit provided, is recording some dummy value in milliseconds here record(5000*timeToBake, TimeUnit.<em>MILLISECONDS</em>) .</p><p>These plots of Stackdriver can be accessed in multiple ways, including with GCP metric explorer, prometheus, Grafana, etc.</p><p>Please keep in mind this approach might or might not suit your project context or needs, and I’m not in the position to say there’s no other way to do it differently or better. I really hope you enjoyed it and had fun reading it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=678a2a5d2e0c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>